setwd("/Users/felipe/Library/CloudStorage/Dropbox/Data Deposit/Track10")

### FRAMCE ###
### FRAMCE ###
### FRAMCE ###
### FRAMCE ###

FR_W10 <- read_sav("UCL_DEL_Tracker_France_Wave10_client.sav")


names(FR_W9)
names(FR_W7)
names(FR_W8)
names(FR_W10)

table(FR_W10$track6_w10) #0-10, 12, recode 12 to 11
table(FR_W10$track8_w10_1) #1-11, 12, needs to be recoded -1 
table(FR_W10$track8_w10_2) #0-10, 12, needs to be recoded -1
table(FR_W10$track8_w10_3) #0-10, 12, needs to be recoded -1
table(FR_W10$track8_w10_4) #0-10, 12, needs to be recoded -1
table(FR_W10$track8_w10_5) #0-10, 12, needs to be recoded -1
table(FR_W10$track9_w10) #0-10, 12, needs to be recoded 12.
table(FR_W10$track10_w10) #0-10, 12, needs to be recoded

FR_W10 <- FR_W10 %>%
  mutate(track6_w10 = dplyr::recode(track6_w10, '12'=11),
         track9_w10 = dplyr::recode(track9_w10,'12'=11 ))

FR_W10 <- FR_W10 %>%
  mutate(track8_w10_1 = track8_w10_1 - 1,
         track8_w10_2 = track8_w10_2 - 1,
         track8_w10_3 = track8_w10_3 - 1,
         track8_w10_4 = track8_w10_4 - 1,
         track8_w10_5 = track8_w10_5 - 1)

write_sav(FR_W10, "DEL_Tracker_France_Wave_10_2024_Data.sav")


library(haven)
FR_W9 <- read_sav("~/Downloads/DEL_Tracker_France_Wave_9_2024_Data.sav")
names(FR_W9)


FR_W9 <- FR_W9 %>% 
  dplyr::rename(track1_w9_1 = track1w9_1,
         track1_w9_2 = track1w9_2,
         track1_w9_3 = track1w9_3,
         track1_w9_4 = track1w9_4,
         track1_w9_5 = track1w9_5,
         track1_w9_6 = track1w9_6, 
         track1_w9_7 = track1w9_7,
         track1_w9_8 = track1w9_8,
         track1_w9_9 = track1w9_9,
         track1_w9_10 = track1w9_10, 
         track8_w9_1 = track8w9_1,
         track8_w9_2 = track8w9_2, 
         track8_w9_3 = track8w9_3, 
         track8_w9_4 = track8w9_4, 
         track8_w9_5 = track8w9_5, 
         track2_w9 = track2w9,
         track3_w9 = track3w9, 
         track4_w9 = track4w9,
         track5_w9 = track5w9,
         track6_w9 = track6w9,
         track7_w9 = track7aw9,
         track8_w9 = track8w9,
         track9_w9 = track9w9,
         track10_w9 = track10w9,
         engage1a_w9 = engage1aw9,
         engage1b_w9 = engage1bw9,
         engage1c_w9 = engage1cw9,
         engage1_w9 = engage1w9,
         engage2_w9 = engage2w9,
         engage3_w9 = engage3w9,
         engage3a_w9 = engage3aw9,
         engage3b_w9 = engage3bw9,
         engage4_w9 = engage4w9,
         engage4a_w9 = engage4aw9,
         engage4b_w9 = engage4bw9,
         engage4c_w9 = engage4cw9,
         engage4d_w9 = engage4dw9)

names(FR_W9)

table(FR_W9$track6_w9) #0-10, 12, recode 12 to 11
table(FR_W9$track8_w9_1) #0-10, 12, needs to be recoded
table(FR_W9$track8_w9_2) #0-10, 12, needs to be recoded
table(FR_W9$track8_w9_3) #0-10, 12, needs to be recoded
table(FR_W9$track8_w9_4) #0-10, 12, needs to be recoded
table(FR_W9$track8_w9_5) #0-10, 12, needs to be recoded
table(FR_W9$track9_w9) #0-10, 12, needs to be recoded

FR_W9 <- FR_W9 %>%
  mutate(track6_w9 = dplyr::recode(track6_w9, '12'=11),
         track9_w9 = dplyr::recode(track9_w9,'12'=11 ))


FR_W9 <- FR_W9 %>%
  mutate(track8_w9_1 = track8_w9_1 - 1,
         track8_w9_2 = track8_w9_2 - 1,
         track8_w9_3 = track8_w9_3 - 1,
         track8_w9_4 = track8_w9_4 - 1,
         track8_w9_5 = track8_w9_5 - 1)

write_sav(FR_W9, "DEL_Tracker_France_Wave_9_2024_Data.sav")
### GREAT BRITAIN ###
### GREAT BRITAIN ###
### GREAT BRITAIN ###
### GREAT BRITAIN ###

GB_W10 <- read_sav("UCL_DEL_Tracker_GB_Wave10_client.sav")

names(GB_W10)

GB_W10 <- GB_W10 %>% 
  rename(education_level = profile_education_level,
         gross_household = profile_gross_household,
         gender = profile_gender,
         religion = profile_religion,
         socialgrade_cie = profile_socialgrade_cie,
        GOR = profile_GOR,
        )

names(GB_W9)

table(GB_W10$track6_w10) #0-10, ALL GOOD
table(GB_W10$track8_w10_1) #0-10, 12, ALL GOOD
table(GB_W10$track8_w10_2) #0-10, 12, ALL GOOD
table(GB_W10$track8_w10_3) #0-10, 12, ALL GOOD
table(GB_W10$track8_w10_4) #0-10, 12, ALL GOOD
table(GB_W10$track8_w10_5) #0-10, 12, ALL GOOD
table(GB_W10$track9_w10) #0-10, 12, ALL GOOD

write_sav(GB_W10, "DEL_Tracker_GreatBritain_Wave_10_2024_Data.sav")

### GERMANY ###
### GERMANY ###
### GERMANY ###
### GERMANY ###

DE_W9 <- read_sav("UCL_DEL_Tracker_Germany_Wave9_client.sav")
DE_W10 <- read_sav("UCL_DEL_Tracker_Germany_Wave10_client.sav")
names(DE_W10)
DE_W10 <- read_sav("~/Downloads/DEL_Tracker_Germany_Wave_8_2023_Data.sav")
names(DE_W8)

DE_W10 <- DE_W10 %>% 
dplyr::rename(track1_w9_1 = track1w9_1,
              track1_w9_2 = track1w9_2,
              track1_w9_3 = track1w9_3,
              track1_w9_4 = track1w9_4,
              track1_w9_5 = track1w9_5,
              track1_w9_6 = track1w9_6, 
              track1_w9_7 = track1w9_7,
              track1_w9_8 = track1w9_8,
              track1_w9_9 = track1w9_9,
              track1_w9_10 = track1w9_10, 
              track8_w9_1 = track8w9_1,
              track8_w9_2 = track8w9_2, 
              track8_w9_3 = track8w9_3, 
              track8_w9_4 = track8w9_4, 
              track8_w9_5 = track8w9_5,
              track2_w9_1 = track2w9_1, 
              track2_w9_2 = track2w9_2, 
              track2_w9_3 = track2w9_3, 
              track2_w9_4 = track2w9_4, 
              track2_w9_5 = track2w9_5,
              track2_w9_6 = track2w9_6, 
              track2_w9_7 = track2w9_7, 
              track2_w9_8 = track2w9_8, 
              track3_w9 = track3w9, 
              track4_w9 = track4w9,
              track5_w9 = track5w9,
              track6_w9 = track6w9,
              track7_w9 = track7w9,
              track8_w9 = track8w9,
              track9_w9 = track9w9,
              track10_w9 = track10w9,
              engage1a_w9 = engage1aw9,
              engage1b_w9 = engage1bw9,
              engage1c_w9 = engage1cw9,
              engage1_w9 = engage1w9,
              engage2_w9 = engage2w9,
              engage3_w9 = engage3w9,
              engage3a_w9 = engage3aw9,
              engage3b_w9 = engage3bw9,
              engage4_w9 = engage4w9,
              engage4a_w9 = engage4aw9,
              engage4b_w9 = engage4bw9,
              engage4c_w9 = engage4cw9,
              engage4d_w9 = engage4dw9)



table(DE_W10$track6_w10) #0-10, 12, recode 12 to 11
table(DE_W10$track8_w10_1) #0-10, 12, needs to be recoded
table(DE_W10$track8_w10_2) #0-10, 12, needs to be recoded
table(DE_W10$track8_w10_3) #0-10, 12, needs to be recoded
table(DE_W10$track8_w10_4) #0-10, 12, needs to be recoded
table(DE_W10$track8_w10_5) #0-10, 12, needs to be recoded
table(DE_W10$track9_w10) #0-10, 12, needs to be recoded


DE_W10 <- DE_W10 %>% 
  mutate(track6_w10 = dplyr::recode(track6_w10, '12'=11),
         track8_w10_1 = dplyr::recode(track8_w10_1, '12'=11),
         track8_w10_2 = dplyr::recode(track8_w10_2, '12'=11),
         track8_w10_3 = dplyr::recode(track8_w10_3, '12'=11),
         track8_w10_4 = dplyr::recode(track8_w10_4, '12'=11),
         track8_w10_5 = dplyr::recode(track8_w10_5, '12'=11),
         track9_w10 = dplyr::recode(track9_w10,'12'=11 ))

write_sav(DE_W10, "DEL_Tracker_Germany_Wave_10_2024_Data.sav")

### UNITED STATES ###
### UNITED STATES ###
### UNITED STATES ###
### UNITED STATES ###

US_W10 <- read_sav("UCL_DEL_Tracker_US_Wave10_client.sav")
US_W9 <- read_sav("UCL_DEL_Tracker_US_Wave9_client.sav")
names(US_W9)

US_W8 <- read_sav("~/Downloads/DEL_Tracker_UnitedStates_Wave_8_2023_Data.sav")
names(US_W8)

table(US_W10$track6_w10) #0-10, 12, all good
table(US_W10$track8_w10_1) #0-10, 12, all good
table(US_W10$track8_w10_2) #0-10, 12, all good
table(US_W10$track8_w10_3) #0-10, 12, all good
table(US_W10$track8_w10_4) #0-10, 12, all good
table(US_W10$track8_w10_5) #0-10, 12, all good
table(US_W10$track9_w10) #0-10, 12, needs to be recoded

US_W10 <- US_W10 %>% 
  mutate(track9_w10 = dplyr::recode(track9_w10,'12'=11 ))


write_sav(US_W10, "DEL_Tracker_UnitedStates_Wave_10_2024_Data.sav")
